Fix up testsuite from recent changes.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 13 Sep 2005 09:09:13 +0000 (09:09 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Tue, 13 Sep 2005 09:09:13 +0000 (09:09 +0000)
(1) Make TESTDIR relative (my directory exceeded 108 chars, breaking sockets)
(2) Make TESTDIR if it doesn't exist
(3) Add dummy xc_domain_getinfo and xc_evtchn_bind_virq for fake libxc
(4) Fix tests broken by b594bb976a743d509f1ffabb5bc698874ab90d8f
(5) domain_cleanup() can be static, as it's not used elsewhere.
(6) With -Werror, "use" unused variable in domain_init() if TESTING
(7) Remove debugging printf on watch without perms.
(8) Loosen timeout in xs_test (valgrind + slow machine == bogus timeouts)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (authored)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/xenstore/Makefile
tools/xenstore/fake_libxc.c
tools/xenstore/testsuite/07watch.test
tools/xenstore/testsuite/14complexperms.test
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_domain.c
tools/xenstore/xenstored_domain.h
tools/xenstore/xenstored_watch.c
tools/xenstore/xs_test.c

index 3ed0d7cff066d84ec2c5211dca1f7db4f912a759..1e5313ff79629d1fadbdf5d6e67480968bc0e846 100644 (file)
@@ -20,7 +20,7 @@ BASECFLAGS+= -I.
 
 CFLAGS  += $(BASECFLAGS)
 LDFLAGS += $(PROFILE) -L$(XEN_LIBXC)
-TESTDIR  = `pwd`/testsuite/tmp
+TESTDIR  = testsuite/tmp
 TESTFLAGS= -DTESTING
 TESTENV  = XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)
 
@@ -80,10 +80,13 @@ check: print-dir testsuite-fast randomcheck-fast print-end
 
 fullcheck: testsuite-run randomcheck stresstest
 
-testsuite-run: xenstored_test xs_test
+$(TESTDIR):
+       mkdir $@
+
+testsuite-run: xenstored_test xs_test $(TESTDIR)
        $(TESTENV) testsuite/test.sh && echo
 
-testsuite-fast: xenstored_test xs_test
+testsuite-fast: xenstored_test xs_test $(TESTDIR)
        @$(TESTENV) testsuite/test.sh --fast
 
 testsuite-clean:
@@ -92,21 +95,21 @@ testsuite-clean:
 # Make this visible so they can see repeat tests without --fast if they
 # fail.
 RANDSEED=$(shell date +%s)
-randomcheck: xs_random xenstored_test
+randomcheck: xs_random xenstored_test $(TESTDIR)
        $(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED) && echo
        $(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED) && echo
        $(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED)
 
-crashme:  xs_crashme xenstored_test
+crashme:  xs_crashme xenstored_test $(TESTDIR)
        rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
        export $(TESTENV); ./xs_crashme 5000 $(RANDSEED) 2>/dev/null
        if [ -n "`cat /tmp/xs_crashme.vglog*`" ]; then echo Valgrind complained; cat /tmp/xs_crashme.vglog*; exit 1; fi
        rm -rf $(TESTDIR)/store $(TESTDIR)/transactions /tmp/xs_crashme.vglog* /tmp/trace
 
-randomcheck-fast: xs_random xenstored_test
+randomcheck-fast: xs_random xenstored_test $(TESTDIR)
        @$(TESTENV) ./xs_random --fast /tmp/xs_random 2000 $(RANDSEED)
 
-stresstest: xs_stress xenstored_test
+stresstest: xs_stress xenstored_test $(TESTDIR)
        rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
        export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret
 
index 50e1db717c4cb929e63d98416b470de5041e0030..a435d65bd0d06cc25c79e9adc87f5145b3fc023e 100644 (file)
@@ -83,6 +83,39 @@ int xc_interface_close(int xc_handle)
        return 0;
 }
 
+int xc_domain_getinfo(int xc_handle __attribute__((unused)),
+                     u32 first_domid, unsigned int max_doms,
+                      xc_dominfo_t *info)
+{
+       assert(max_doms == 1);
+        info->domid = first_domid;
+
+        info->dying    = 0;
+        info->shutdown = 0;
+        info->paused   = 0;
+        info->blocked  = 0;
+        info->running  = 1;
+
+        info->shutdown_reason = 0;
+
+        if ( info->shutdown && (info->shutdown_reason == SHUTDOWN_crash) )
+        {
+            info->shutdown = 0;
+            info->crashed  = 1;
+        }
+
+       return 1;
+}
+
+int xc_evtchn_bind_virq(int xc_handle __attribute__((unused)),
+                       int virq __attribute__((unused)),
+                       int *port)
+{
+       if (port)
+               *port = 0;
+       return 0;
+}
+
 static void send_to_fd(int signo __attribute__((unused)))
 {
        int saved_errno = errno;
index 7b19c57227655f35b533aa5126616fb977628a86..f95888d8bba69c8624ad1e1bb1d9b860a8cb1695 100644 (file)
@@ -34,12 +34,13 @@ expect 1:/dir/newdir:token
 1 close
 2 close
 
-# We don't get a watch from our own commands.
-watch /dir token
-mkdir /dir/newdir
-expect waitwatch failed: Connection timed out
-waitwatch
-close
+# Changed in b594bb976a743d509f1ffabb5bc698874ab90d8f
+## We don't get a watch from our own commands.
+#watch /dir token
+#mkdir /dir/newdir
+#expect waitwatch failed: Connection timed out
+#waitwatch
+#close
 
 # ignore watches while doing commands, should work.
 watch /dir token
index 97ff76e6de86600f52701fcd8470a32cdf3ace83..4290a0db6fce6d097a8328484c996d11ee870d91 100644 (file)
@@ -30,10 +30,8 @@ getperm /dir/file
 expect *Permission denied
 setperm /dir/file 0 NONE 
 watch /dir/file token 
-setid 0
-write /dir/file create contents
-rm /dir/file
-setid 1
+1 write /dir/file create contents
+1 rm /dir/file
 expect waitwatch failed: Connection timed out
 waitwatch
 unwatch /dir/file token 
@@ -78,10 +76,8 @@ getperm /dir/file
 expect *Permission denied
 setperm /dir/file 0 NONE 
 watch /dir/file token 
-setid 0
-write /dir/file create contents
-rm /dir/file
-setid 1
+1 write /dir/file create contents
+1 rm /dir/file
 expect waitwatch failed: Connection timed out
 waitwatch
 unwatch /dir/file token 
index c43e6372c06142a99761da8a22c60c2d6c593457..bce4d17e8dec5f8151c05ff8f37236332c079d68 100644 (file)
@@ -1640,8 +1640,10 @@ static void daemonize(void)
 
        /* Session leader so ^C doesn't whack us. */
        setsid();
+#ifndef TESTING        /* Relative paths for socket names */
        /* Move off any mount points we might be in. */
        chdir("/");
+#endif
        /* Discard our parent's old-fashioned umask prejudices. */
        umask(0);
 }
index 1d5328879790e58a6080555ee0f6f513156793f8..e09acee6df54fc5f36e12aa46d4d2093a996147f 100644 (file)
@@ -218,6 +218,26 @@ static int destroy_domain(void *_domain)
        return 0;
 }
 
+static void domain_cleanup(void)
+{
+       xc_dominfo_t dominfo;
+       struct domain *domain, *tmp;
+       int released = 0;
+
+       list_for_each_entry_safe(domain, tmp, &domains, list) {
+               if (xc_domain_getinfo(*xc_handle, domain->domid, 1,
+                                     &dominfo) == 1 &&
+                   dominfo.domid == domain->domid &&
+                   !dominfo.dying && !dominfo.crashed && !dominfo.shutdown)
+                       continue;
+               talloc_free(domain->conn);
+               released++;
+       }
+
+       if (released)
+               fire_watches(NULL, "@releaseDomain", false);
+}
+
 /* We scan all domains rather than use the information given here. */
 void handle_event(int event_fd)
 {
@@ -371,26 +391,6 @@ void do_release(struct connection *conn, const char *domid_str)
        send_ack(conn, XS_RELEASE);
 }
 
-void domain_cleanup(void)
-{
-       xc_dominfo_t dominfo;
-       struct domain *domain, *tmp;
-       int released = 0;
-
-       list_for_each_entry_safe(domain, tmp, &domains, list) {
-               if (xc_domain_getinfo(*xc_handle, domain->domid, 1,
-                                     &dominfo) == 1 &&
-                   dominfo.domid == domain->domid &&
-                   !dominfo.dying && !dominfo.crashed && !dominfo.shutdown)
-                       continue;
-               talloc_free(domain->conn);
-               released++;
-       }
-
-       if (released)
-               fire_watches(NULL, "@releaseDomain", false);
-}
-
 void do_get_domain_path(struct connection *conn, const char *domid_str)
 {
        struct domain *domain;
@@ -457,6 +457,7 @@ int domain_init(void)
 
 #ifdef TESTING
        eventchn_fd = fake_open_eventchn();
+       (void)&st;
 #else
        /* Make sure any existing device file links to correct device. */
        if ((lstat(EVTCHN_DEV_NAME, &st) != 0) || !S_ISCHR(st.st_mode) ||
index 332eae65e8087625eb5f3bd5975663dfe7dcf898..a896e1a3af3c7ea4a26d9b13f47def4456c8b15f 100644 (file)
@@ -28,10 +28,6 @@ void do_introduce(struct connection *conn, struct buffered_data *in);
 /* domid */
 void do_release(struct connection *conn, const char *domid_str);
 
-/* Enumerate domains and release connections for non-existant or dying
- * domains. */
-void domain_cleanup(void);
-
 /* domid */
 void do_get_domain_path(struct connection *conn, const char *domid_str);
 
index b413f4c697c24ed9123e4473eb5b10b1bddfaf3f..e40318ee2f587db565024f39c9fcacac7e8e4a95 100644 (file)
@@ -105,7 +105,6 @@ static void add_event(struct connection *conn,
         */
        if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK) &&
            !check_event_node(node)) {
-               fprintf(stderr, "No permission for %s\n", node);
                return;
        }
 
index fa41600086df10bcdb004142bd59660645637727..58445b9f25502b4cc690acaaccd9ee0590780294 100644 (file)
@@ -43,7 +43,7 @@
 
 static struct xs_handle *handles[10] = { NULL };
 
-static unsigned int timeout_ms = 200;
+static unsigned int timeout_ms = 500;
 static bool timeout_suppressed = true;
 static bool readonly = false;
 static bool print_input = false;